<!--#include file="admin/Includes/constants.asp"-->
<!--#include file="admin/Includes/validate.asp"-->
<%
SSLMode = 1
'------------Authentication----------------------------
Verify
'------------Authentication----------------------------
MakeSSL 1
Dim Action, AlbumID, FavoriteType, FavoriteID
Dim strMes, Result, ArticleID
Dim aData, rCount, nRows, hasData, referer
Dim AlbumName, AlbumType, AddOK, isLogin, strTitle

AddOK=false
Action = request("act")
ArticleID=request("aid")
if request.Form("r") <> "" then 
	referer = request.Form("r") 	
Else
	referer = Request.ServerVariables("HTTP_REFERER")	
End If
If request.Form("fid") > "" Then
	FavoriteID = request.Form("fid") 
Else
	FavoriteID = request.Querystring("fid") 
End If
AlbumID = getData("AlbumID")

'Get album for selection

	strSQL = "{CALL a_user_favimg_album_sel('"&CookieID&"')}"
	exec(strsql)
	If Not RS Is Nothing Then
		If Not RS.EOF Then
			aData = RS.getrows
			nRows = Ubound(aData,2)	
			hasData=True			
		End If
	End If


If Action="TẠO ALBUM" Then
	AlbumName = getData("rqAlbumName")		'ten album	
	If getData("rqAlbumType") <> "" Then
		AlbumType = getData("rqAlbumType")	'Loại Album
	Else
		AlbumType=0
	End If
	
	strSQL = "{CALL a_album_sel ('add','','',N'"&AlbumName&"',"&AlbumType&",'"&CookieID&"')}"	
	exec(strsql)
		
		If Not RS.EOF Then
			result = RS(0)
			If result=0 Then
				AlbumID=RS(1)
				AddOK=true
			End If			
		End If		
End If

If Action = "LƯU VÀO ALBUM" or AddOK=true Then
	
	FavoriteType = 3 '3.picture, 2.articles, 1. subcategory
	strSQL = "{CALL a_user_favimg_add('add','"&CookieID&"',"&AlbumID&","&FavoriteType&","&FavoriteID&")}"
	exec(strsql)
	Result = RS(0)
	If result = 0 then
		strMes ="Không thể lưu hình vì hình đã có trong album này"		
	Else
		isLogin=instr(referer,"login.asp")
		
		CloseCon
		'If isLogin > 0 Then
			response.Redirect("detail.asp?aid="&ArticleID&"&msg=2&ckid="&ckid)
			response.End()
		'Else
			'response.redirect(referer)
			'response.End()	
		'End If
	end if
end if
CloseCon

If hasData Then
	strTitle="Hay tạo album mới"	
Else
	strTitle="Tạo album mới"
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<Meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Thoitrang-dang ky thanh vien</title>
	<Meta http-equiv=" content-language" content ="vi">
	<Meta name="Robots" content="noindex,nofollow">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="icon" href="favicon.ico" type="image/x-icon"> 
	<link rel="STYLESHEET" type="text/css" href="system/styles.css">	
    <script language="JavaScript" type="text/javascript" src="admin/javascripts/validateVN.js"></script>				
</head>

<body>
<div id="container">
<div id="bt2"><img src="hinh-thoi-trang/bg_top.gif" width="1049" height="20"></div>
<div id="tp">
<table border="0" cellpadding="0" cellspacing="0" width="990" align="center">	
	<!--top-->
	<!--#include file="system/top.asp" -->
	<!--/top-->
	<tr bgcolor="#6b5a60">
		<td width="160" style="height:1px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
		<td width="522" valign="top" rowspan="2">		
		<!--body content-->		
			<!--cover-->		
		<table border="0" cellpadding="0" cellspacing="1" width="100%" bgcolor="#B6A8AD">			
			<tr><td colspan="3" style="padding-left:12px; "><img src="hinh-thoi-trang/chon-album-hp.gif" width="400" height="40"></td></tr>
			<tr>
				<!--col left-->		
				<td valign="top" height=680>
					<table cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF" width=100%>
						<% if strMes <> "" then%>
						<tr><td colspan="2" class="lsTitle" style="color:#8D0045;padding:10 0 10 12; background-color:#F7F6BD"><%=strMes%></td></tr>
						<%end if%>
						<tr>
							<% If hasData Then %>
							<td style="padding-left:9px;padding-top:15px;display:block;" height="100%" valign=top>
							<form name ="frmSelect" action="user_favimg_add.asp?ckid=<%=ckid%>" method="post">
							<input type="hidden" name="fid" value="<%= FavoriteID %>">
							<input type="hidden" name="r" value="<%= referer %>">
							<input type="hidden" name="aid" value="<%= ArticleID %>">
								<table border="0" cellpadding="3" cellspacing="0">		
									<tr>
										<td class="paging">Album</td>
										<td>
										<select name="AlbumID" style="width:200px" class="txtInput" id="Album">											
											<%	for rCount =0 to nRows %>
											<option value="<%=aData(0,rCount) %>"><%=aData(1,rCount) %></option>
											<%  Next   %>																					
										</select>
										</td>
									</tr>												
									<tr>
										<td>&nbsp;</td>
										<td><input type="submit" name="act" value="LƯU VÀO ALBUM" class="btnGo" style="width:200px"></td>
									</tr>
									</form>
								</table>						
							</td>
							<%	End If %>	
							<!--add new album-->
							<td style="padding:15px 10px 15px 9px;" valign=top>
							<table bgcolor="#D8D2BD" cellpadding="0" cellspacing="0" border="0">
								<tr>
									<td align="left"><img src="hinh-thoi-trang/box_topL.gif" width="10" height="10"/></td>
									<td width="80%"><img src="hinh-thoi-trang/de_clear.gif" width="1" height="0" border="0"/></td>
									<td align="right"><img src="hinh-thoi-trang/box_topR.gif" width="10" height="10"/></td>
								</tr>
								<tr>
									<td><img src="hinh-thoi-trang/de_clear.gif" width="0" height="0" border="0"/></td>
									<td>
										<table border="0" cellpadding="3" cellspacing="0">
											
												<form name ="frmAdd" action="user_favimg_add.asp?ckid=<%=ckid%>" method="post" onSubmit="return isValid(this)">
												<input type="hidden" name="fid" value="<%= FavoriteID %>">
												<input type="hidden" name="r" value="<%= referer %>">	
												<input type="hidden" name="aid" value="<%= ArticleID %>">
												<tr><td  colspan="2" class="lsTitle" style="font-weight:bold;color:#7C6787; padding:0px 0px 7px 3px;"><%= strTitle %></td></tr>								
												<tr>
													<td class="paging" nowrap>Tên Album</td>
													<td><input type="text" id="Tên Album" name="rqAlbumName" value="" class="txtInput" style="width:134px;"></td>
												</tr>
												<tr>
													<td class="paging" nowrap>Loại Album</td>
													<td><select name="rqAlbumType" id="Loại Album" class="txtInput" style=" width:140px;">									
														<option value="0">Đồ tôi thích</option>
														<option value="1">Đồ tôi muốn mua</option>										
													</select>
													</td>
												</tr>															
												<tr>
													<td>&nbsp;</td>
													<td><input type="submit" name="act" value="TẠO ALBUM" class="btnGo" style="width:140px;"></td>
												</tr>
												
												</form>				
											</table>		
									</td>
									<td><img src="hinh-thoi-trang/de_clear.gif" width="0" height="0" border="0"/></td>
								</tr>
								<tr>
									<td align="left"><img src="hinh-thoi-trang/box_bottomL.gif" width="10" height="10"/></td>
									<td width="80%"><img src="hinh-thoi-trang/de_clear.gif" width="0" height="0" border="0"/></td>
									<td align="right"><img src="hinh-thoi-trang/box_bottomR.gif" width="10" height="10"/></td>
								</tr>
							</table>
			
										
							</td>
							<!--/add new album-->
						</tr>
						<tr><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="15" border="0"></td></tr>						
					</table>						 
				</td>
				<!--/col left-->							
			</tr>
		</table>
			<!--/text-->		
		<!--/body content-->
		</td>
		<td width="308" style="width:0px;"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td>
	</tr>
	<!--main body-->
	<tr bgcolor="#ffffff">
		<td bgcolor="#000000" width="160" valign="top">
		<!--#include file="system/left_user.asp" -->
		</td>
		<!--missing 1 TD because of Rowspan-->		
		<td bgcolor="#614B00" width="308" valign="top">
			<table border="0" cellpadding="0" cellspacing="0" width="308" align="right">
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<form name="frmSearch" action="listing.asp?ckid=<%=ckid%>" method="post">
				<tr bgcolor="#8D0045">
					<td width="154" valign="top" height="33" ><input type="text" name="search" value="Tìm kiếm" size="22" class="txtSearch"></td>
					<td width="154" valign="top" style="padding-top:7px;padding-left:3px;"><input type="submit" name="go" value="TÌM" class="btnGo"></td>
				</tr>
				</form>
				<tr bgcolor="#000000"><td colspan="2"><img src="hinh-thoi-trang/de_clear.gif" alt="" width="1" height="1" border="0"></td></tr>
				<!--Ads Starts-->
				<tr><td align="center" colspan="2"><img src="hinh-quang-cao/neimanmarcus350x250.jpg" alt="" width="300" height="250" border="0"></td></tr>
				<!--Ads Ends-->
			</table>
		</td>
	</tr>
	<!--/main body-->
	<!--#include file="system/bottom.asp" -->
</table>
</div>
<div id="bt2"><img src="hinh-thoi-trang/bg_bottom.gif" width="1049" height="20"></div>
</div>
</body>
</html>
